

package com.hazelcast.client.impl.protocol.codec.custom;

import com.hazelcast.client.impl.protocol.ClientMessage;
import com.hazelcast.client.impl.protocol.Generated;
import com.hazelcast.client.impl.protocol.codec.builtin.CustomTypeFactory;

import static com.hazelcast.client.impl.protocol.ClientMessage.BEGIN_FRAME;
import static com.hazelcast.client.impl.protocol.ClientMessage.END_FRAME;
import static com.hazelcast.client.impl.protocol.codec.builtin.CodecUtil.fastForwardToEndFrame;

@SuppressWarnings("unused")
@Generated("995df2fe069cf8dec376159b9ecc2919")
public final class BTreeIndexConfigCodec {

    private BTreeIndexConfigCodec() {
    }

    public static void encode(ClientMessage clientMessage, com.hazelcast.config.BTreeIndexConfig bTreeIndexConfig) {
        clientMessage.add(BEGIN_FRAME.copy());

        CapacityCodec.encode(clientMessage, bTreeIndexConfig.getPageSize());
        MemoryTierConfigCodec.encode(clientMessage, bTreeIndexConfig.getMemoryTierConfig());

        clientMessage.add(END_FRAME.copy());
    }

    public static com.hazelcast.config.BTreeIndexConfig decode(ClientMessage.ForwardFrameIterator iterator) {
        // begin frame
        iterator.next();

        com.hazelcast.memory.Capacity pageSize = CapacityCodec.decode(iterator);
        com.hazelcast.config.MemoryTierConfig memoryTierConfig = MemoryTierConfigCodec.decode(iterator);

        fastForwardToEndFrame(iterator);

        return CustomTypeFactory.createBTreeIndexConfig(pageSize, memoryTierConfig);
    }
}
